*Load data
use "C:\Users\abrah\Dropbox\Fear and coordination\11_JEPS_Replication_Files\01_Data\Data for Analyses in Stata\data_stata.dta", clear
 

*Drop periods that had a coding mistake
recode action_i (0=.) (1=.) if Period==16 & Date=="190418_1853"
recode action_i (0=.) (1=.) if Period==11 & Date=="190425_1928"

set scheme s1mono

*Graph for rational choices
*Code actions as rational choices that are consistent with the equilibrium strategy for rounds with uncertainty
gen rationalnoise=.
recode rationalnoise(.=1) if action_i==1 & signal<=1
recode rationalnoise(.=0) if action_i==1 & signal>1
recode rationalnoise(.=0) if action_i==0 & signal<=1
recode rationalnoise(.=1) if action_i==0 & signal>1


*Determine which choices are rationalizable when game is played with no noise for rounds without uncertainty
gen mob=y-signal
gen rationalnonoise=.
recode rationalnonoise(.=1) if (action_i==1 & mob>=-c)|(action_i==0 & signal>=c)
recode rationalnonoise(.=0) if (action_i==1 & mob<-c)|(action_i==0 & signal<c)


*Put into one variable
gen rational=.
recode rational(.=1) if rationalnoise==1 & (Type==1|Type==3)
recode rational(.=0) if rationalnoise==0 & (Type==1|Type==3)
recode rational(.=1) if rationalnonoise==1 & Type==2
recode rational(.=0) if rationalnonoise==0 & Type==2

*Drop pre-experiment periods
drop if Type==4

*Install cibar and create the graph
ssc install cibar
cibar rational, over(Treatment Type) vce(cluster Date)